package com.lmt_15;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.List;

public class XMLTest {
    public static void main(String[] args) throws Exception {
        //  解析xml文件
         SAXReader saxReader = new SAXReader();
         Document read = saxReader.read("src/com/lmt_15/hello.xml");
         Element root = read.getRootElement();
        System.out.println(root.getName()); // 拿到根元素对象

         Element user = root.element("user");
        System.out.println(user.elementText("name"));
        System.out.println(user.attributeValue("id"));
        System.out.println(user.elementText("address" +
                ""));


    }
}
